< previous page page_622 next page >

Page 622
Use the RowDividerStyle to determine what type of line is drawn between each row of data. You can choose from several options, including turning off the row dividers completely. Note that the RowDividerStyle property does not affect the dividers of the record selectors.
The Enabled property controls whether user interaction with the grid is allowed. If this property is set to False, the user cannot scroll, select cells, or modify data. However, the grid and some data still are visible on the screen.
In addition to the properties that control how the DataGrid control looks, the following three Boolean properties in the General tab control which data operations are allowed:
AllowAddNewControls whether the user can add a new record to the recordset displayed in the data grid (False by default). If this property is set to True, a blank row is added to the end of the data so that the user can enter a new record. The record selector for the AddNew row is marked with an asterisk (*).
AllowDeleteControls whether the user can delete a record from the underlying recordset. To delete a row, use the record selector to highlight it, and then press the Delete key. This property is False by default.
AllowUpdateControls whether the user can edit an existing record (True by default). Setting this property to False makes each cell in the grid act like a locked text box: You can select text using the mouse and copy it to the Clipboard, but you cannot change it.
Each of these three properties can be set at runtime or designtime. Setting all of them to False means that your grid will be read-only.
Keyboard Options
Although you can select cells using the mouse, you might prefer using the keyboard because it allows you to perform operations much faster. The DataGrid has several properties that control keyboard behavior. You can set these properties in the Keyboard tab of the Property Pages or at runtime with code.
For example, the AllowArrows property determines whether the arrow keys can be used to navigate between cells on the DataGrid. If you set this property to False, the user has to use the Tab key or the mouse to put the cursor in a specific cell.
note.gif When you are editing a cell, the arrow key moves within the current cell. To put the grid in move mode, single-click a cell so that it is highlighted. You should then be able to use the arrow keys to move from cell to cell. square.gif

Handling the Tab key on any type of grid control presents a minor dilemma for programmers because the standard behavior is for the Tab key to cause the focus to move to the next control on the form. Fortunately, the DataGrid's TabAction property allows you to set up the Tab key for your specific needs. This property has three settings:
0 dbgControlNavigationPressing the Tab key while in the DataGrid moves the focus off the DataGrid to the next control in the form's tab order. In this case, the DataGrid acts like a standard control as far as Visual Basic is concerned.

 
< previous page page_622 next page >